package com.example;

import com.example.pojo.User;
import com.example.service.IUserService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class mybatisplusService {

    @Resource
    private IUserService userService;

    @Test
    void testgetCount() {
//        SELECT COUNT( * ) FROM user
        long count = userService.count();
        System.out.println("总记录数为：" + count);

    }

    @Test
    void testAdd() {
//        批量添加
        List<User> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setName("zlm" + i);
            user.setAge(20 + i);
            list.add(user);
        }
        boolean b = userService.saveBatch(list);
        System.out.println("b = " + b);
    }
}
